#ifndef CATEGORY_H
#define CATEGORY_H

#include <QObject>
#include <QString>
#include <QMessageBox>

class MoneyCategory : public QObject
{
    Q_OBJECT

    Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
    Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
    Q_PROPERTY(bool editMode READ editMode WRITE setEditMode NOTIFY editModeChanged)
    Q_PROPERTY(float total READ total WRITE setTotal NOTIFY totalChanged)
    Q_PROPERTY(float totalExpenses READ totalExpenses WRITE setTotalExpenses NOTIFY totalExpensesChanged)
    Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
    Q_PROPERTY(QColor colorRgb READ colorRgb WRITE setColorRgb NOTIFY colorRgbChanged)
    Q_PROPERTY(int percentage READ percentage WRITE setPercentage NOTIFY percentageChanged)

public:
    MoneyCategory(QObject *parent = 0) : QObject(parent) { this->m_total = 0; }
    MoneyCategory(int id, QString name, QString description, bool editMode, QObject *parent = 0)
        : QObject(parent)
    {
        this->m_id = id;
        this->m_name = name;
        this->m_description = description;
        this->m_editMode = editMode;
        this->m_total = 0;
    }

    void setId(int id)
    {
        if (id != m_id) {
            this->m_id = id;
            emit idChanged();
        }else this->m_id = id;
    }
    void setName(QString name)
    {
        if (name != m_name) {
            this->m_name = name;
            emit nameChanged();
        } else this->m_name = name;
    }
    void setDescription(QString description)
    {
        if (description != m_description) {
            this->m_description = description;
            emit descriptionChanged();
        } else this->m_description = description;
    }
    void setEditMode(bool editMode)
    {
        if (editMode != m_editMode) {
            this->m_editMode = editMode;
            emit editModeChanged();
        } else this->m_editMode = editMode;
    }
    void setTotal(float total)
    {
        if (total != m_total) {
            this->m_total = total;
            emit totalChanged();
        } else this->m_total = total;
    }
    void setTotalExpenses(float totalExpenses) { this->m_totalExpenses = totalExpenses; }

    void setColor(QString color) {
        m_color = color;
    }
    void setColorRgb(QColor colorRgb) { m_colorRgb = colorRgb; }
    void setPercentage(int percentage) { m_percentage = percentage; }

    int id() { return m_id; }
    QString name() { return m_name; }
    QString description() { return m_description; }
    bool editMode() { return m_editMode; }
    float total() { return m_total; }
    float totalExpenses() { return m_totalExpenses; }
    QString color() { return m_color; }
    QColor colorRgb() { return m_colorRgb; }
    int percentage() { return m_percentage; }
signals:
    void idChanged();
    void nameChanged();
    void descriptionChanged();
    void editModeChanged();
    void totalChanged();
    void totalExpensesChanged();
    void colorChanged();
    void colorRgbChanged();
    void percentageChanged();
private:
    int m_id;
    bool m_editMode;
    QString m_name;
    QString m_description;
    float m_total;
    float m_totalExpenses;
    QString m_color;
    QColor m_colorRgb;
    int m_percentage;
};

#endif // CATEGORY_H
